1. Field of the Invention
The present invention relates to a method and apparatus for encoding and decoding based on intra prediction, and more particularly, to a method and apparatus for encoding a direction of intra prediction of a current block that is to be encoded while increasing the probability of predicting the direction of intra prediction by using neighboring blocks, thereby increasing the compression rate of encoding.
2. Description of the Related Art
In video compression methods, such as MPEG-1, MPEG-2, and MPEG-4H.264/MPEG-4 Advanced Video coding (AVC), a picture is divided into macro blocks in order to encode the picture. Next, each of the macroblocks is encoded using inter prediction and intra prediction. Then, an optimal encoding mode is selected in consideration of the data sizes of the encoded macro blocks and the extent of degradation of the original macro blocks, and the macro blocks are encoded in the optimal coding mode.
In intra prediction, a current block of a current picture is encoded using the values of pixels that are spatially adjacent to the current block, rather than referring to a reference picture. First, a prediction value of the current block is calculated using the values of the adjacent pixels. Next, only the difference between the prediction value and a pixel value of the original current block is encoded. Here, an intra prediction mode is largely classified into a 4×4 intra prediction mode, an 8×8 intra prediction mode, and a 16×16 intra prediction mode according to luminance components; and an intra prediction mode according to color difference components.
FIG. 1 illustrates conventional 16×16 intra prediction modes. Referring to FIG. 1, the conventional 16×16 intra prediction modes include four modes: a vertical mode, a horizontal mode, a direct current (DC) mode, and a plane mode.
FIG. 2 illustrates conventional 4×4 intra prediction modes. Referring to FIG. 2, the conventional 4×4 intra prediction modes include 9 modes: a vertical mode 0, a horizontal mode 1, a direct current (DC) mode 2, a diagonal down-left mode 3, a diagonal down-right mode 4, a vertical right mode 5, a vertical left mode 6, a horizontal-up mode 7, and a horizontal-down mode 8.
A prediction mode number indexed to each of the above modes is determined by the frequency of use of the mode. Statistically, the vertical mode 0 is most frequently used so as to perform intra prediction on a target block, and the horizontal-up mode 8 is least frequently used.
For example, a method of performing prediction encoding on a 4×4 current block according to the vertical mode 0 will be described. First, pixel values of the 4×4 current block are predicted using the values of pixels A through D adjacent to the top of the 4×4 current block. That is, 4 pixel values of the first column of the 4×4 current block are predicted using the value of the pixel A, 4 pixel values of the second column of the 4×4 current block are predicted using the value of the pixel B, 4 pixel values of the third column of the 4×4 current block are predicted using the value of the pixel C, and 4 pixel values of the fourth column of the 4×4 current block are predicted using the value of the pixel D. Next, the differences between each of the prediction values of the 4×4 current block, which are predicted using the pixels A through D, and each of actual values of pixels of the original 4×4 current block are calculated, and the differences are encoded, thereby generating a bitstream of the 4×4 current block.
According to the H.264 standard, a picture is encoded by encoding a current macro block in a total of 13 modes: the 4×4 intra prediction modes and the 16×16 intra prediction modes, and performing intra prediction encoding in one of the 13 modes, which is selected as the optimal mode. The optimal mode is selected in consideration of the residue and distortion between the original block and a predicted block.
In order to decode an intra prediction encoded bitstream, a receiving side that receives the bitstream must obtain information regarding a direction of intra prediction. To this end, the information regarding the direction of intra prediction is included in the bitstream during intra prediction encoding and the bitstream is transmitted to the receiving side. A predetermined encoding method is also used so as to reduce the bit rate when the information regarding the direction of intra prediction is included in the bitstream. Intra prediction encoding according to the H.264 standard will now be described.
FIGS. 3A and 3B illustrate a conventional method of encoding a direction of intra prediction. It is assumed that the number of an intra prediction mode of a current block 30 is P, the number of an intra prediction mode of an upper block 31 is A, and the number of an intra prediction mode of a left block 32 is L.
In video intra prediction encoding according to the H.264 standard, information regarding a direction of intra prediction of the current block 30 is encoded based on the directions of respective intra prediction of the upper block 31 and the left block 32. The upper block 31 and the left block 32 are neighboring blocks that have been encoded before encoding the current block 30, and each of them has a prediction mode number indicating the direction of intra prediction.
First, the number of the intra prediction mode of the current block 30 is compared with the minimum value of the prediction mode numbers of the upper block 31 and the left block 32.
If the minimum value is identical to the prediction mode number of the current block 30, the direction of intra prediction is encoded as “1” and the result of encoding is included in a bitstream. A receiving side that receives the bitstream determines the minimum value of the prediction mode numbers of the upper block 31 and the left block 32 as the prediction mode number of the current block 30, and decodes the bitstream in a direction of intra prediction, which corresponds to the prediction mode number of the current block 30. As described above, a prediction mode number is determined according to the frequency of use of each mode, and it is highly probable that a direction of predicting the current block 30 is similar to the directions of predicting neighboring blocks. Thus, it is highly probable that the minimum value of the prediction mode numbers of the neighboring blocks is identical to the prediction mode number of the current block. Therefore, the probability of expressing information regarding the direction of intra prediction of the current block 30 by using one bit is high, and the information is compressed based on the probability.
If the minimum value is not identical to the prediction mode number of the current block 30, “0” is inserted into the bitstream in order to indicate this fact. Since the prediction mode number of the current block 30 cannot be determined from the neighboring blocks in this case, the information regarding the direction of intra prediction is also inserted into the bitstream in the form of XXX, i.e., at the rate of 3 bits. Since there are 9 prediction mode numbers ranging from 0 to 8 and the minimum value is different from the prediction mode number of the current block 30, eight cases corresponding to the other prediction mode numbers excluding the minimum value are expressed with 3 bits. More specifically, when the prediction mode number of the current block 30 is less than the minimum value of the prediction mode numbers of the upper block 31 and the left block 32, a binary number of the prediction mode number of the current block 30 is in the form of XXX. However, when the prediction mode number of the current block 30 is greater than the minimum value, a value obtained by subtracting 1 from the binary number of the prediction mode number of the current block 30 is in the form of XXX.
In a conventional method, information regarding a direction of intra prediction of a current block is compressed only when the prediction mode value of the current block is identical to a minimum value of the prediction mode numbers of neighboring blocks. However, if they are not identical, the information regarding the direction of intra prediction is expressed with a total of 4 bits.
For example, it is assumed that a prediction mode 1 is used for the current block 30 of FIG. 3A, a prediction mode 0 is used for the upper block 31, and a prediction mode 1 is used for the left block 32. In this case, according to the conventional method, a minimum value of the prediction mode numbers is 0 and is thus not identical to the prediction mode number of the current block 30. Accordingly, the information of the direction of prediction must be expressed with 4 bits. That is, although the current block 30 uses the same prediction mode together with one of the neighboring blocks, the information regarding the direction of prediction is not compressed.
Accordingly, there is a need for a method and apparatus for encoding and decoding based on intra prediction, which are capable of compressing information regarding a direction of prediction with a higher probability than when using the conventional method.